package win.smartown.app.common;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.ViewGroup;
import android.webkit.WebView;

import com.just.library.AgentWeb;
import com.just.library.ChromeClientCallbackManager;

import win.smartown.app.R;
import win.smartown.app.base.BaseActivity;

/**
 * Created by smartown on 2017/5/5 16:28.
 * Desc:
 */
public class WebActivity extends BaseActivity implements ChromeClientCallbackManager.ReceivedTitleCallback {

    private AgentWeb mAgentWeb;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setBaseView(R.layout.activity_web);
        mAgentWeb = AgentWeb.with(this)//传入Activity
                .setAgentWebParent((ViewGroup) findView(R.id.webView), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))//传入AgentWeb 的父控件 ，如果父控件为 RelativeLayout ， 那么第二参数需要传入 RelativeLayout.LayoutParams ,第一个参数和第二个参数应该对应。
                .useDefaultIndicator()// 使用默认进度条
                .defaultProgressBarColor() // 使用默认进度条颜色
                .setReceivedTitleCallback(this) //设置 Web 页面的 title 回调
                .createAgentWeb()//
                .ready()
                .go(getIntent().getStringExtra("url"));
    }

    @Override
    public void onReceivedTitle(WebView webView, String s) {

    }
}
